/**
 * 
 */
package cc.monggo.web.controller.baiduapp;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import cc.monggo.common.AbstractBaseController;
import cc.monggo.common.Constants;
import cc.monggo.web.form.RegisterForm;

/**
 * @author Administrator
 * 
 */
@Controller
@RequestMapping("/baiduApp")
public class BaiduAppController extends AbstractBaseController {

	/**
	 * demo的应用入口
	 * 
	 * @param request
	 * @param response
	 * @param form
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/demo")
	public ModelAndView demo(HttpServletRequest request,
			HttpServletResponse response, RegisterForm form) throws Exception {
		ModelAndView mv = new ModelAndView("/baiduApp/demo/demoApp",
				Constants.FORM_COMMAND_KEY, form);
		return mv;
	}

	/**
	 * 获取月份
	 * 
	 * @param request
	 * @param response
	 * @param form
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getMonth2", method = RequestMethod.GET)
	public ModelAndView getMonth(HttpServletRequest request,
			HttpServletResponse response, RegisterForm form) throws Exception {
		ModelAndView mv = new ModelAndView("/baiduApp/demo/pop_monthBox",
				Constants.FORM_COMMAND_KEY, form);
		mv.addObject("content", "SUCCESS");
		return mv;
	}

	/**
	 * 获取月份,返回对象
	 * 
	 * @param request
	 * @param response
	 * @param form
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getMonth", method = RequestMethod.GET)
	public Object getMonthByJson(HttpServletRequest request,
			HttpServletResponse response, RegisterForm form) throws Exception {
		Map map = new HashMap();
		map.put("content", "SUCCESS");
		return map;
	}
	
	@RequestMapping(value = "/openToday", method = RequestMethod.GET)
	public ModelAndView openToday(RegisterForm form){
		ModelAndView mv = new ModelAndView("/baiduApp/demo/pop_today", Constants.FORM_COMMAND_KEY, form);
		Map map = new HashMap<String,String>();
		map.put("a", "妮子大衣");
		map.put("b", "反季格子裙");
		form.setDemoMap(map);
		
		return mv;
	}

	/**
	 * 打印字符流的拦截测试
	 * 
	 * @param request
	 * @param response
	 * @param form
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/printWriteDemo", method = RequestMethod.GET)
	public ModelAndView getMonthByprintWriteDemo(HttpServletRequest request,
			HttpServletResponse response, RegisterForm form) throws Exception {
		ModelAndView mv = new ModelAndView("/baiduApp/demo/pop_monthBox",
				Constants.FORM_COMMAND_KEY, form);
		return mv;
	}
}
